﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ViewModelBase.cs" company="http://buginbox.wordpress.com/">
//   Copyright (c) GNU General Public License version 2 (GPLv2)
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System.ComponentModel.Composition;
using Microsoft.Practices.Prism.ViewModel;
using Wpf.Core.Control;

namespace Wpf.Core.ViewModel
{
    /// <summary>
    /// ViewModel de base dont doivent dériver tous les ViewModel Aucune sécurité n'est définie
    /// </summary>
    public class ViewModelBase : NotificationObject, IPartImportsSatisfiedNotification
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModelBase"/> class.
        /// </summary>
        public ViewModelBase()
        {
            _viewUniqueId = "No view ID. View model ID = " + GetType().Name;
        }

        /// <summary>
        /// Finalizes an instance of the <see cref="ViewModelBase"/> class
        /// </summary>
        ~ViewModelBase()
        {
        }

        /// <summary>
        /// Called when MEF imports are satisfied.
        /// </summary>
        public virtual void OnImportsSatisfied()
        {
        }

        /// <summary>
        /// View Unique Id
        /// </summary>
        private string _viewUniqueId;

        /// <summary>
        /// Gets or sets the view unique id.
        /// </summary>
        /// <value>
        /// The view unique id. 
        /// </value>
        public string ViewUniqueId
        {
            get
            {
                return _viewUniqueId;
            }

            set
            {
                _viewUniqueId = value;
                RaisePropertyChanged(() => ViewUniqueId);
            }
        }

        /// <summary>
        /// Gets or sets Order.
        /// </summary>
        public int Order
        {
            get;
            set;
        }

        /// <summary>
        /// The view
        /// </summary>
        private UserControlBase _view;

        /// <summary>
        /// Gets or sets the view
        /// </summary>
        /// <value>
        /// The view. 
        /// </value>
        public UserControlBase View
        {
            get
            {
                return _view;
            }

            set
            {
                _view = value;
                RaisePropertyChanged(() => View);
            }
        }
    }
}